package com.imooc.order.controller;

import com.imooc.product.client.ProductClient;
import com.imooc.product.common.DecreaseStockInput;
import com.imooc.product.common.ProductInfoOutput;
import lombok.extern.slf4j.Slf4j;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.GetMapping;
import org.springframework.web.bind.annotation.RestController;

import java.util.Arrays;
import java.util.List;

/**
 * ClientController
 *
 * @author leon.cheng
 * @date 2018/12/7 16:16
 **/
@RestController
@Slf4j
public class ClientController {
    @Autowired
    private ProductClient productClient;

    @GetMapping("/getProductList")
    public List<ProductInfoOutput> getProductList(){
        List<ProductInfoOutput> list= productClient.listForOrder(Arrays.asList("1543216319545178504","haha456"));
        return list;
    }
    @GetMapping("/productDecreaseStock")
    public String productDecreaseStock(){
        productClient.decreaseStock(Arrays.asList(new DecreaseStockInput("1543216319545178504",2),
                new DecreaseStockInput("haha456",4)));
        return "ok";
    }
}
